﻿using RPAVIEW.util;
using System.Drawing;
using System.Windows.Controls;
using FCursor = System.Windows.Forms.Cursor;

namespace RPAVIEW.views.EditPage.flows.KeyBoardInputN {
    /// <summary>
    /// Input.xaml 的交互逻辑
    /// </summary>
    public partial class Input:BaseParamViewAction{
        private static SpecialKeyBoard? keyBoard;
        public Input() {
            InitializeComponent();
        }

        public override void UpdateSource() {
            this.inputText.GetBindingExpression(TextBox.TextProperty).UpdateSource();
        }

        private void SoftKeyBoard(object sender, System.Windows.RoutedEventArgs e) {
            Point p =  FCursor.Position;
            SpecialKeyBoard keyBoard = WindowUtil.GetWindow<SpecialKeyBoard>();
            if(keyBoard == null) { 
                keyBoard = new SpecialKeyBoard(this.inputText);
            }
            keyBoard.Top = p.Y;
            keyBoard.Left = p.X - keyBoard.Width / 2;
            keyBoard.Show();
            keyBoard.Activate();
        }

        private void MoveToEnd(object sender, System.Windows.RoutedEventArgs e) {
            inputText.SelectionStart = inputText.Text.Length;
        }
    }
}
